class Validate {
  show() {
    console.log(this)
  }
  //获取元素
  query(name) {
    return document.querySelector(name)
  }

  confirm_Password(password, confirmPassword, message, errEl, eventType) {
    //获取元素
    let elements = document.querySelectorAll(`[name='${password}'],[name='${confirmPassword}']`)
    let This = this
    //遍历元素
    elements.forEach(function (elem) {
      //键盘监听事件
      elem.addEventListener(eventType, function () {
        const confirmPasswordValue = This.query(`[name='${confirmPassword}']`).value
        const passwordValue = This.query(`[name='${password}']`).value

        //对比是否一致
        if (passwordValue != confirmPasswordValue) {
          This.query(errEl).innerHTML = message
        } else {
          This.query(errEl).innerHTML = ''
        }
      })
    })
  }
}
